package com.vcredit.creditcat.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.tempuri.SendMessageService;
import org.tempuri.SendMessageServiceSoap;

import java.net.MalformedURLException;
import java.net.URL;

@Component
public class GetSendMessageFromVBS {
	private Logger logger = LoggerFactory.getLogger(GetSendMessageFromVBS.class);

	@Value("${send.msg.url}")
	private String SEND_MSG_URL;

	private SendMessageServiceSoap sendMessageServiceSoap = null;
	
	public SendMessageServiceSoap getSendMessageServiceSoap() throws Exception {
		if (sendMessageServiceSoap == null) {
			SendMessageService msgService = null;
			try {
				msgService = new SendMessageService(new URL(SEND_MSG_URL));
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
			sendMessageServiceSoap = msgService.getSendMessageServiceSoap();
		}
		return sendMessageServiceSoap;
	}
}
